<!DOCTYPE html>
<html lang="en">
<head>
    <title>意向客户报表</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="Cache-Control" content="no-store, must-revalidate">
    <meta http-equiv="expires" content="Wed, 26 Feb 1997 08:21:57 GMT">
    <meta http-equiv="expires" content="-1">
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="shortcut icon" href="/dist/img/icon.png" type="image/x-icon">
    <script src="https://file.ggxqce.com/web/vue.min.js"></script>

    <style>
        [v-cloak] {
            display: none;
        }

        * {
            -webkit-box-sizing: border-box;
            -moz-box-sizing: border-box;
            box-sizing: border-box;
            font-size: 12px;
        }

        body {
            margin: 1px;
            background: #fff;
        }

        table {
            border-spacing: 0;
            border-collapse: collapse;
            display: table;
        }

        table.text-center, table.text-center td, table.text-center th {
            text-align: center;
            font-size: 12px;
        }

        .table-bordered > thead > tr > th, .table-bordered > tbody > tr > th, .table-bordered > tfoot > tr > th, .table-bordered > thead > tr > td, .table-bordered > tbody > tr > td, .table-bordered > tfoot > tr > td {
            border: 1px solid #cbcbcd;
            font-weight: normal;
            height: 24px;
        }

        .table th {
            background: #F8F8F8;
        }
        .table-bordered {
            border: 1px solid #cbcbcd;
        }

        .table {
            width: 100%;
            max-width: 100%;
        }

        .hidden {
            display: none;
        }
        .lineOne {
            text-align: left;
        }

        .lineOne span {
            max-height: 24px;
            line-height: 24px;
            overflow: hidden;
            text-overflow: ellipsis;
            display: -webkit-box;
            -webkit-box-orient: vertical;
            -webkit-line-clamp: 1;
            text-align: left;
        }
        .mScrollBox {
            float: left;
            position: relative;
            overflow: hidden;
        }
        .infoReport{
            text-align: center;
            margin: 0;
            margin-bottom: 10px;
        }
        .moduleName{
            height: 20px;
            line-height: 20px;
            background: #f8f8f8;
            font-weight: bold;
            font-size: 14px;
        }
        .oaReportNav{
            position: relative;
        }
        .toggleDiv{
            height: 20px;
            line-height: 20px;
            margin-bottom: 10px;
        }
        .toggleDiv div{
            width: 50%;
            float: left;
            text-align: center;
        }
        .toggleDiv div.active{
            border-bottom: 2px solid #2289ee;
        }
        .div-td-content-more {
            position: absolute;
            height: auto;
            z-index: 999;
            line-height: 20px;
            background-color: #d3e8fd;
            padding: 8px 6px;
            border: 1px solid #e8e8ea;
            display: none;
        }
        .div-td-content-more i {
            width: 15px;
            height: 12px;
            background: url("/dist/img/more-icon.png");
            position: absolute;
            right: 50px;
            top: -12px;
        }
        .pd_1{padding-left:.1rem}
        .btn-blue {
            border: none;
            background: #2a8ced;
            color: #fff;
            font-size: 0.22rem;
            height: 0.48rem;
            width: 14%;
        }
        .btn-blue.focus, .btn-blue:focus, .btn-blue:hover {
            color: #fff;
            text-decoration: none;
        }
    </style>
</head>
<body>
<section class="content"  id="app" >
    <div class="div-td-content-more"><i></i></div>
    <div style="height: 25px;margin:10px 5px;">
        <input type="text" placeholder="关键字" class="form-control pull-left input-sm" style="width:85%;height: .48rem;vertical-align: top;" v-model="key" class="pd_1">
        <button type="button" class="btn btn-blue" @click="getList">查询</button>
    </div>
    <div class="box-body no-padding iframeH2" style="overflow: auto;width: 100%;" id="scrollDiv">
        <table class="table table-bordered text-center table-width">
            <thead>
            <tr>
                <!--<th style="width: 8%;">序号</th>-->
                <th style="width: 18%">客户姓名</th>
                <th style="width: 15%">电话</th>
                <th style="width: 16%">意向机型</th>
                <th style="width: 16%">购买时间</th>
                <th style="width: 16%">付款方式</th>
                <th style="width: 19%">基本情况</th>
            </tr>
            </thead>
            <tbody>
        <tr v-for="(item,i) in intentionalCustomer.list">
            <!--<td>{{i+1}}</td>-->
            <td @click="openCustomerList(item.id,item.name)" ><span style="text-align:center; ">{{item.name}}</span></td>
            <td @click="openCustomerList(item.id,item.name)" >{{trims(item.tel)}}</td>
            <td @click="openCustomerList(item.id,item.name)" >{{item.intentionModel}}</td>
            <td @click="openCustomerList(item.id,item.name)" >{{item.buyDate}}</td>
            <td @click="openCustomerList(item.id,item.name)" >{{item.buyType}}</td>
            <td class="lineOne"><span>{{item.otherCondition}}</span></td>
            </tr>
            </tbody>
        </table>
    </div>
        <div class="oa-pager" style="margin-top: 5px;margin-left: 5px;text-align: center;" v-if="isAll">
            共
            <span id="allCount"> 0 </span>条记录&nbsp;&nbsp;&nbsp;
            <span id="nowPage"> 1 </span>/<span id="allPage">1</span>&nbsp;&nbsp;&nbsp;
            <span class="oa-pager-button" id="first">首页</span>
            <span class="oa-pager-button" id="prev" style="border-bottom: 1px solid red;">上一页</span>
            <span class="oa-pager-button" id="next" style="border-bottom: 1px solid red;">下一页</span>
            <span class="oa-pager-button" id="last">尾页</span>
        </div>


    <!-- /.box-body -->
</section>
<!--rem.js-->
<script src="/dist/js/pages/rem/rem.js"></script>
<!--JQ-->
<script src="https://file.ggxqce.com/web/jquery-2.2.3.min.js"></script>
<!--插件JS-->
<script src="/dist/plugins/scroll/myScroll.js"></script>
<!--框架已定义 JS-->
<!--oa自定义  JS-->
<script src="/dist/js/oaApp.js"></script>

<script type="text/javascript" src="/dist/plugins/lhgdialog/lhgdialog.min.js?self=true"></script>
<script>
    $.ajaxSetup({
        global: true,
        type: "POST",
        cache: false,
        dataType: "json",
        contentType: 'application/json;charset=utf-8',
        beforeSend: function () {
        },
        complete: function () {

        },
        error: function (e) {
            alert('error' + e.responseText);
        }
    });
    $.extend($.wyui, {
        page: {
            urlParams: null,
            queryParams: {
                requestPage: 1,
                pageSize: 30
            },
            dataUrl: '',
            getByPage_callback: null,
            createQueryParams: function () {
            },
            getByPage: function (type) {
                if(type=="scroll"){
                    $.wyui.page.queryParams.requestPage++;
                }
                $.ajax({
                    url: $.wyui.page.dataUrl,
                    data: JSON.stringify($.wyui.page.queryParams),
                    beforeSend: function () {

                    },
                    complete: function () {
                    },
                    success: function (r) {
                        $("#allCount").html(r.data.sendData.pager.recordCount);
                        $("#nowPage").html($.wyui.page.queryParams.requestPage);
                        if (r.data.sendData.pager.pageCount == 0) {
                            r.data.sendData.pager.pageCount = 1;
                        }
                        $("#allPage").html(r.data.sendData.pager.pageCount);
                        if(type=="scroll"){
                            $.wyui.page.getByPage_scroll_callback(r.data.sendData.records);
                        }else{
                            $.wyui.page.getByPage_callback(r.data.sendData.records);
                            if($.wyui.page.getByPage_callback_new){
                                $.wyui.page.getByPage_callback_new(r.data.sendData);
                            }
                        }

                    }
                });
            }
        },
        postMethod: function (url, data, callback, sync, id) {
            if (!id) {
                id = "#app"
            }
            $.ajax({
                url: server.ip + url,
                async: sync ? false : true,
                data: JSON.stringify(data),
                beforeSend: function () {

                },
                complete: function () {
                    setTimeout(function () {
                    }, 1000);

                },
                success: function (r) {
                    if (!r.e.code) {
                        callback(r.data.sendData);
                    } else {
                        alert(r.e.desc);
                    }
                },
                error: function (e) {
                    alert(url + e.responseText);
                }
            });
        },
    });

</script>
<script type="text/javascript">
    function refresh() {
        $.wyui.page.getByPage();
    }
    $(function () {
        $("body").on("click", ".lineOne", function (e) {
            if ($(".div-td-content-more").is(":hidden")) {
                var text = $(this).text();
                if (text != "") {
                    text = "<i></i>" + text;
                    $(".div-td-content-more").html(text).css({
                        "width":"100%",
                        "left": 0,
                        "top": ($(this).offset().top + $(this).outerHeight()) + "px"
                    }).show();
                    e.stopPropagation();
                }
            } else {
                $(".div-td-content-more").hide();
            }
        });
        $("body").on("click", ".div-td-content-more", function (e) {
            e.stopPropagation();
        });
        $("body").on("click", function () {
            $(".div-td-content-more").hide();
        });
    });

    var app = new Vue({
        el:'#app',
        data:{
            userId:getUrlParamObj().userId,
            key:"",
            isAll:getUrlParamObj().isAll,
            intentionalCustomer:{
                time: getUrlParamObj().dateTime,
                list: []
            },
        },
        methods:{
            //去空格
            trims: function (data) {
//                console.log(data);
                var data = data.replace(/[ ]/g, "");
                return data;
            },
            //打开意向客户列表
            openCustomerList: function (id, name) {
                var that = this;
                var obj = {
                    type: 'lookPersonnelDetail',
                    url: '/reportForm/customer/intentionalCustomerInfoApp.html?id=' + id+"&name="+name,
                    id: id,
                    name: name,
                    dateTime: ''
                }
                console.log(JSON.stringify(obj));
                prompt(JSON.stringify(obj));
            },
            getList: function () {
                var that = this;
                if (that.isAll=='true') {
                    $.wyui.page.dataUrl = server.ip + urlConfig.report.intentCustomer.getAllReportCustomer
                    $.wyui.page.queryParams.requestPage=1;
                    $.extend($.wyui.page.queryParams, {userId: app.userId, key: app.key});
                    $.wyui.page.getByPage();
                } else {
                    $.wyui.page.dataUrl = server.ip + urlConfig.report.intentCustomer.getForPersonalIntentCustomerList;
                    $.wyui.page.queryParams.requestPage=1;
                    $.extend($.wyui.page.queryParams, {userId: app.userId, key: app.key});
                    $.wyui.page.getByPage()
                }

            }
        },
        mounted:function () {
            $(".oa-pager-button").click(function () {
                var allPage = parseInt($("#allPage").html());
                switch (this.id) {
                    case "first":
                        $.wyui.page.queryParams.requestPage = 1;
                        break;
                    case "next":
                        $.wyui.page.queryParams.requestPage++;
                        break;
                    case "prev":
                        $.wyui.page.queryParams.requestPage--;
                        break;
                    case "last":
                        $.wyui.page.queryParams.requestPage = allPage;
                        break;
                    default:
                        break;
                }
                if ($.wyui.page.queryParams.requestPage == 0) {
                    $.wyui.page.queryParams.requestPage = 1;
                } else if ($.wyui.page.queryParams.requestPage > allPage) {
                    $.wyui.page.queryParams.requestPage = allPage;
                }
                $.wyui.page.getByPage();
            });
        }
    });
    if (getUrlParamObj().isAll == "true") {
        $.wyui.page.dataUrl = server.ip + urlConfig.report.intentCustomer.getAllReportCustomer;
    }
    else {
        $.wyui.page.dataUrl = server.ip + urlConfig.report.intentCustomer.getForPersonalIntentCustomerList;
    }
    //    if($.wyui.page.urlParams.isAll=="false"){
    //        $.wyui.page.dataUrl = server.ip + urlConfig.report.intentCustomer.getForPersonalIntentCustomerList;
//    $.wyui.page.queryParams.pageType = $.wyui.page.urlParams.pageType;
    $.extend($.wyui.page.queryParams, {userId: app.userId, key: app.key});
    $.wyui.page.getByPage()
    $.wyui.page.getByPage_callback = function (records) {
        console.log(records)
        app.intentionalCustomer.list = records;
        document.getElementById("scrollDiv").scrollTop = 0;
    };
    $.wyui.page.getByPage_scroll_callback = function (list) {
        if (list.length < 30) {
            isLoad = false;
        } else {
            for (var i = 0; i < list.length; i++) {
                app.intentionalCustomer.list.push(list[i]);
            }
            isLoad = true;
        }
    }
</script>
<script>
    /************************滚动加载******************************/
    var divscroll = document.getElementById('scrollDiv');

    function divScroll() {
        var wholeHeight = divscroll.scrollHeight;
        var scrollTop = divscroll.scrollTop;
        var divHeight = divscroll.clientHeight;
        console.log(scrollTop + divHeight, wholeHeight)
        if (scrollTop + divHeight >= wholeHeight - 2) {
//            alert('滚动到底部了！');
            if (isLoad) {
                isLoad = false;
                setTimeout($.wyui.page.getByPage("scroll"), 1000);

            }

            //这里写动态加载的逻辑，比如Ajax请求后端返回下一个页面的内容
        }

    }

    divscroll.onscroll = divScroll;
</script>
</body>
</html>